package com.bit.talkoftoday;

import java.io.File;

import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.SeekBar;
import android.widget.Toast;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class LockScreenActivity extends Activity {
	private SeekBar mUnlockBar;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.activity_lock_screen);
		
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED 
				| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
		
		mUnlockBar = (SeekBar) findViewById(R.id.seekBar2);
		mUnlockBar.setThumbOffset(10);
		mUnlockBar.setMax(100);
		mUnlockBar.getProgressDrawable().setColorFilter(Color.rgb(255, 255, 155), Mode.SRC_IN);
		mUnlockBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
		
			@Override
			public void onProgressChanged(SeekBar seekBar, int progress,
					boolean fromUser) {
			}

			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {
			}

			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
				if (seekBar.getProgress() >= 95) {
					seekBar.setProgress(100);
					seekBar.setEnabled(false);
					seekBar.setFocusable(false);
					finish();
					
				} else {
					seekBar.setProgress(0);
				}
			}
		});
		String imgPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + "/Camera/rhemacard.jpg";
		File file = new File(imgPath);
		if(file.exists() == false){
			return;
		}
		Drawable d = Drawable.createFromPath(imgPath);
		findViewById(R.id.lock_layout).setBackgroundDrawable(d);
		findViewById(R.id.lock_title).setVisibility(View.INVISIBLE);
	}

	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void onUserLeaveHint() {
		// TODO Auto-generated method stub
		super.onUserLeaveHint();
		finish();
	}
}
